How to demonstrate the final keyword in PHP | PHP programs
We will create a class that contains a final method Method(), and as we know that we cannot override a final method, that's why it will generate a syntax error.
<?php
class ParentClass
{
final public function Method()
{
printf("Parent::Method() called<br>");
}
}
class Child extends ParentClass
{
final public function Method()
{
printf("Child::Method() called<br>");
}
}
$ChildObj = new Child();
$ChildObj->Method();
?>


